home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 April / macformat-023.iso / Shareware City / Developers / NeoPersist 3.0.8 folder / NeoIncludes / CNeoIterator.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-13  |  2.4 KB  |  70 lines  |  [TEXT/MMCC]

  1. /************************************************************
  2.  *
  3.  *    Created: Sunday, December 7, 1992 8:56:00 PM
  4.  *    CNeoIterator.h
  5.  *    C++ class definition for index iterator objects
  6.  *
  7.  *
  8.  *    Copyright © Neologic Systems 1992-1994. All Rights Reserved.
  9.  *    All rights reserved
  10.  *
  11.  *
  12.  * Within a class, references to permanent objects are kept
  13.  * in a sorted list called an index. It is often necessary to
  14.  * serial traverse a list of objects in an index. Iterators
  15.  * make the process of traversing an index easier. They also
  16.  * allow indices to be used as all other collection classes.
  17.  *
  18.  ***********************************************************/
  19. #pragma once            /* Include this file only once */
  20. #ifndef __CNeoIterator__
  21. #define __CNeoIterator__ 1
  22.  
  23. #include "NeoTypes.h"
  24.  
  25. class CNeoPersist;
  26. class CNeoNode;
  27.  
  28. class CNeoIterator {
  29. public:
  30.                         /** Instance Methods **/
  31.                         CNeoIterator(CNeoNode *aNode = nil, CNeoSelect *aKey = nil, const Boolean aForward = TRUE, const Boolean aReset = TRUE);
  32.     virtual                ~CNeoIterator(void);
  33.  
  34.                         /** Access Methods **/
  35.     short                getIndex(void) const {return fIndex;}
  36.     CNeoNode *            getNode(void) const {return fNode;}
  37.     Boolean                isForward(void) const {return fForward;}
  38.     void                setForward(const Boolean aForward) {fForward = aForward;}
  39.     void                setNode(CNeoNode *aNode, const short aIndex);
  40.  
  41.                         /** Object List Management Methods **/
  42.     virtual Boolean        cross(const Boolean aForward = TRUE);
  43.     virtual CNeoPersist *
  44.                         currentObject(void);
  45.     virtual void *        doUntil(NeoTestFunc1 aFunc, void *aParam = nil);
  46.     virtual Boolean        leap(const long aDelta);
  47.     virtual Boolean        more(void);
  48.     virtual CNeoPersist *
  49.                         nextObject(void);
  50.     virtual CNeoPersist *
  51.                         previousObject(void);
  52.     virtual CNeoNode *    removeCurrent(void);
  53.     virtual void        reset(void);
  54.  
  55.     Boolean                fForward;                // In which direction do we progress?
  56.     Boolean                fLinear;                // Are we doing a linear search over the index?
  57.     Boolean                fMatched;                // Is the current object a match?
  58.     Boolean                fDone;                    // Have we reached the end of the list?
  59.     short                fIndex;                    // Current entry in the current node.
  60.     CNeoNode *            fNode;                    // The current node.
  61.     CNeoSelect *        fKey;                    // The key that determines which objects to include.
  62.  
  63.     CNeoIterator *        fNextIter;                // Forward reference to iterators looking at fNode
  64.     CNeoIterator *        fPrevIter;                // Backward reference to iterators looking at fNode
  65.  
  66. protected:
  67.     virtual Boolean        advance(const short aDelta);
  68. };
  69. #endif
  70.